<?php
/**
 * Object Relational Persistence Mapping Class for table: examination_type
 *
 * @package	com.athena
 * @author	LHV
 */
class ExaminationType extends ORDataObject {

	/**#@+
	 * Fields of table: examination_type mapped to class members
	 */
	var $examination_type_id		= '';
	var $vi_name	= '';
	var $en_name	= '';	
	var $value		= '';
	var $percent	= '';
	/**#@-*/
	
	const TYPE_NEW_EXAM	=	1;
	const TYPE_RE_EXAM	=	2;
	/**
	 * DB Table
	 */
	var $_table = 'examination_type';

	/**
	 * Primary Key
	 */
	var $_key = 'examination_type_id';
	
	/**
	 * Internal Name
	 */
	var $_internalName = 'ExaminationType';

	/**
	 * Handle instantiation
	 */
	function ExaminationType() {
		parent::ORDataObject();
	}

	function getAllItems() {
		$ds = new Datasource_sql();
		$field	=	L10nHelper::getLocale();
		$field 	=	L10nHelper::changeField($field, "name");
		$sql = array(
			'cols' 	=> "examination_type_id, $field name",
			'from'	=> "$this->_table"
		);
		$ds->setup($this->_db, $sql);
		return $ds->toArray('examination_type_id', 'name');
	}
	
	function isExist() {			
		$sql = "SELECT $this->_key from $this->_table 
			where $this->_key = " . (int)$this->get_id();
		$res = $this->_execute($sql);
		if ($res && !$res->EOF) {	
			return true;
		}
		return false;
	}

	
}
?>
